# import os
# import shutil

# arr = [0,1,2,4,6]
# for i in arr:
#     count = 0
#     input_folder = "G:\\Desktop\\搅拌站文件\\Material_level\\yunnan_data_crop\\1215"
#     output_folder = "G:\\Desktop\\搅拌站文件\\Material_level\\test"
#     input_folder = os.path.join(input_folder,str(i))
#     output_folder = os.path.join(output_folder,str(i))

#     file_list = os.listdir(input_folder)
#     print(input_folder,"\t",output_folder)
#     for filename in file_list:
#         count = count + 1
#         input_filepath = os.path.join(input_folder,filename)
#         if filename.endswith(('.jpg')):
#             new_filename = str(count) + '.jpg'
#             print(new_filename)
#             output_filepath = os.path.join(output_folder,new_filename)
#             shutil.copy(input_filepath,output_filepath)
#     print("重命名完成")
    

import os

def batch_rename_files(folder_path):
    # 获取文件夹中的所有文件名
    files = os.listdir(folder_path)
    
    # 遍历文件夹中的每个文件
    count = 0
    for index, file_name in enumerate(files,i):
        # 构建新的文件名
        new_name = f"{count + 1}.jpg"  # 这里假设文件是jpg格式的，可以根据实际情况修改后缀名
        count = count = 1
        # 构建文件的完整路径
        old_path = os.path.join(folder_path, file_name)
        new_path = os.path.join(folder_path, new_name)
        
        # 重命名文件
        os.rename(old_path, new_path)
        print(f"重命名文件：{file_name} -> {new_name}")

# 调用函数并传递文件夹路径和前缀
arr = [0,1,2,4,6] # 0,1,2,4,6
for i in arr: 
    root_path = "G:\Desktop\搅拌站文件\Material_level\yunnan_data_crop\\1224"
    img_path = os.path.join(root_path,str(i))
    print(img_path)
    batch_rename_files(img_path)
